package com.example.viewmodel_livedata.viewModelDemo

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

class CViewModel(defaultCount: Int = 0) : ViewModel() {

    private val _count: MutableLiveData<Int> = MutableLiveData(defaultCount)

    val count: LiveData<Int>
        get() = _count

    fun onCountChanged(count_: Int) {
        _count.postValue(count_)
    }

    fun onClear(zeroCount : Int){
        _count.postValue(zeroCount)
    }
}